package com.nami.message.acl.repository.phismsgs;

import com.nami.message.domain.model.pmsg.PChatMsgModel;
import com.nami.message.domain.repository.PrivateHisMsgRepository;
import com.nami.message.acl.repository.phismsgs.convertor.Model2PrivateHisMsgsDOConvertor;
import com.nami.message.core.mybatis.dataobject.PrivateHisMsgsDO;
import com.nami.message.core.mybatis.mapper.PrivateHisMsgsMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class PrivateHisMsgRepositoryImpl implements PrivateHisMsgRepository {

    private final PrivateHisMsgsMapper privateHisMsgsMapper;

    @Override
    public boolean add(PChatMsgModel msgModel) {

        PrivateHisMsgsDO privateHisMsgsDO = Model2PrivateHisMsgsDOConvertor.toDO(msgModel);
//        PrivateHisMsgsDO privateHisMsgsDO = PrivateHisMsgsConvert.INSTANCE.convert(msgModel);

        int result = privateHisMsgsMapper.insert(privateHisMsgsDO);
        if (result < 1) {
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }
}
